<?php
namespace Amis\feedback;

use Amis\Basics\AmisBasics;

class Spinner extends AmisBasics
{
    public string $type = 'spinner';

    public function show(bool $show = true)
    {
        $this->show = $show;
        return $this;
    }

    public function className($className)
    {
        $this->className = $className;
        return $this;
    }

    public function spinnerClassName($spinnerClassName)
    {
        $this->spinnerClassName = $spinnerClassName;
        return $this;
    }

    public function spinnerWrapClassName($spinnerWrapClassName)
    {
        $this->spinnerWrapClassName = $spinnerWrapClassName;
        return $this;
    }

    /**
     * 组件大小 sm lg
     * @param $size
     * @return $this
     */
    public function size($size)
    {
        $this->size = $size;
        return $this;
    }

    /**
     * 组件图标，可以是amis内置图标，也可以是字体图标或者网络图片链接，作为 ui 库使用时也可以是自定义组件
     * @param string $icon
     * @return $this
     */
    public function icon(string $icon)
    {
        $this->icon = $icon;
        return $this;
    }

    /**
     * 配置组件文案，例如加载中...
     * @param string $tip
     * @return $this
     */
    public function tip(string $tip)
    {
        $this->tip = $tip;
        return $this;
    }

    /**
     * 配置组件 tip 相对于 icon 的位置
     * top, right, bottom, left
     * @param string $tipPlacement
     * @return $this
     */
    public function tipPlacement(string $tipPlacement = 'bottom')
    {
        if (in_array($tipPlacement, ['top', 'right', 'bottom', 'left'])) {
            $this->tipPlacement = $tipPlacement;
        }
        return $this;
    }

    public function delay(int $delay = 0)
    {
        $this->delay = $delay;
        return $this;
    }

    public function overlay(bool $overlay = true)
    {
        $this->overlay = $overlay;
        return $this;
    }

    public function body(array $body)
    {
        $this->body = $body;
        return $this;
    }
}